import logging
from typing import Optional

_LOGGER = logging.getLogger("device")


def get_device_logger(device_phone: Optional[str]) -> logging.LoggerAdapter:
    """返回带设备手机号的LoggerAdapter，便于GUI按设备路由日志"""
    phone = device_phone or ""
    return logging.LoggerAdapter(_LOGGER, {"device_phone": phone})

